import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '@/views/home/HomeView.vue'
import LoginView from '@/views/login/LoginView.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: '12306',
      component: HomeView,
      redirect: '/ticketSearch',
      children: [
        {
          path: '/ticketManage', 
          name: '车票管理',
          children: [
            {
              path: '/ticketSearch', 
              name: '车票查询',
              component: () => import('@/views/pages/ticketSearch/TicketSearch.vue')
            }
          ]
        },
        {
          path: '/infoManage', 
          name: '信息管理',
          children: [
            {
              path: '/userInfo', 
              name: '用户信息',
              component: () => import('@/views/pages/userInfo/UserInfo.vue')
            },
            {
              path: '/passenger', 
              name: '乘车人',
              component: () => import('@/views/pages/passenger/PassengerInfo.vue')
            }
          ]
        },
        {
          path: '/orderManage', 
          name: '订单管理',
          children: [
            {
              path: '/ticketList', 
              name: '车票订单',
              component: () => import('@/views/pages/ticketList/TicketList.vue')
            },
            {
              path: '/personalTicket', 
              name: '本人车票',
              component: () => import('@/views/pages/personalTicket/PersonalTicket.vue')
            }
          ]
        }
      ]
    },
    {
      path: '/login',
      name: 'login',
      component: LoginView
    }
  ]
})

export default router
